﻿@using CoralNode.Core.Entity.Enums
@using CoralNode.MvcClient.Helper
@using Coralcode.Utils.Basic
@model CoralNode.Core.Entity.Domains.Prototype.PrototypeCategoryDomain
@{
    ViewBag.Title = "Edit";
    ViewData["curr"] = "category";
}
@Html.IncludePage("CoralAdmin/prototype", "_Left", new { current = "prototype" })
<div id="pbody">
    <div class="extra">
        <div class="pbody_top">
            <span class="ico ico_setting_system"></span><span class="t t_c">内容设计&nbsp;&nbsp;/&nbsp;&nbsp;<b
                class=" t_small f_no">编辑分类</b></span>
        </div>
        <div id="main">
            @Html.IncludePage("CoralAdmin/Prototype","_tab",new{prototypeId=ViewBag.Prototype.Id})
            <div class="funsearch p_1 pl_2 pr_2 extra_normal border-bottom1">
                <a href="/m/prototype/listCategory?prototypeid=@Model.PrototypeId" class="ico ico_back btn f_r mt_0-5"></a>
            </div>
            <form id="spform" action="/m/prototype/editCategory/@Model.Id?prototypeId=@Model.PrototypeId" method="post" enctype="multipart/form-data">
                @if (@ViewBag.Msg != null) {
                    <div class="error_msg">
                        @ViewBag.Msg.Msg
                    </div>
                }
                <div class="pt_1 slideswitch pl_2 pr_2" data-js="slideswitch">
                    <div class="switch_tab">
                        <span class="btn"><i class="ico ico_slideswitch_show"></i></span>主要信息
                    </div>
                    <div class="table_form form_main switch_cnt">
                        <div class="pl_2">
                            @Html.AntiForgeryToken()
                            @Html.ValidationSummary(true)
                            <table>
                                <tbody>
                                    <tr>
                                        <th width="60">分类名称<span class="rq">*</span></th>
                                        <td>
                                            @Html.TextBoxFor(m => m.Title, new { @class = "text w_37 required" })
                                            @Html.HiddenFor(m => m.Id)
                                        </td>
                                    </tr>
                                    <tr>
                                        <th width="60">Url别名<span class="rq">*</span></th>
                                        <td>
                                            @Html.TextBoxFor(m => m.Slug, new { @class = "text w_37 required" })
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>原型</th>
                                        <td>
                                            <div class="select_owner w_20 " data-meta="{name:'PrototypeId',value:'@Model.PrototypeId',fun:'selectPrototype', btn:'<span class=\'ico ico_slide_down\'></span>' , clickbtn:'<span class=\'ico ico_slide_up\'></span>'}">
                                                <ul>
                                                    @foreach (var item in @ViewBag.PrototypeList) {
                                                        if (Model.PrototypeId == @item.Id) {
                                                            <li data-value="@item.Id">@item.Title
                                                            </li>
                                                        } else {
                                                            <li data-value="@item.Id">@item.Title
                                                            </li>
                                                        }
                                                    }
                                                </ul>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>父分类</th>
                                        <td>
                                            <div class="ztreeContainer">
                                                <input type="text" class="text w_12 required js_ztree_trigger" id="category_title" value="@ViewBag.ParentTitle " />
                                                <input type="hidden" name="ParentId" id="parent_id" value="@Model.ParentId" />
                                                <label class="mt_0-5">
                                                    <input type="button" id="menuBtn" class="btn_2 js_ztree_trigger" value="选择"></label>
                                                <ul id="parent_list" class="ztree js_parentCategory" style="margin-top: 0; width: 180px;">
                                                </ul>
                                                <textarea class="js_ztree_data">@ViewBag.CategoryData</textarea>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>分类图</th>
                                        <td>
                                            <input type="hidden"  name="Icon" value="@Model.Icon"/>
                                            <ul class="list_img" href="/m/file/upload" data-js="listimg">
                                                <li class="btn li_add js_openuploader" data-meta="{data:'{module:\'@Model.Prototype.Code/category\'}',multi:false,method:'add',type:'image'}">
                                                    <span class="ico ico_upload_image"></span>
                                                </li>
                                            </ul>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>分页数</th>
                                        <td>
                                            @Html.TextBoxFor(n => n.PageSize, new { @class = "text w_37" })
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>分类状态</th>
                                        <td>
                                            @foreach (var item in @ViewBag.CategoryStatusList) {
                                                if (Model.IsValid == @item.Value) {
                                                    <label class="mr_2">
                                                        <input class="f_l mt_0-5 mr_0-5" type="radio"  name="IsValid" value="@item.Value" checked="checked"><span
                                                                                                                                                                class="f_l">@item.Key</span></label>
                                                } else {
                                                    <label class="mr_2">
                                                        <input class="f_l mt_0-5 mr_0-5" type="radio"  name="IsValid" value="@item.Value"><span
                                                                                                                                              class="f_l">@item.Key</span></label>
                                                }
                                            }
                                        </td>
                                    </tr>

                                    <tr>
                                        <th>描述</th>
                                        <td>
                                            @Html.TextAreaFor(m => m.Description)
                                            <script type="text/javascript">
                                                UE.getEditor('Description')
                                            </script>
                                            @Html.HiddenFor(m => m.SiteId)
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="submitbox p_2 extra_normal">
                    <input type="submit" class="btn_1" value="提    交" />
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    function selectPrototype($obj) {
        prototypeId = $obj.find("input[type='hidden']").val();
        $('#category_title').val("根分类");
        $('#parent_id').val(0);
        $.post("/m/prototype/GetCategoryList", { prototypeId: prototypeId, parentId: "@Model.ParentId", categoryId: "@Model.Id" }, function (data) {
            $(".js_parentCategory").data("zTree").setData(data);
        });
    }

</script>
